import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'home',
    component: Home,
    children: [{
        path: 'new',
        name: 'new',
        component: () => import( /* webpackChunkName: "mall" */ '../components/home/New.vue')
      },
      {
        path: 'last',
        name: 'last',
        component: () => import( /* webpackChunkName: "mall" */ '../components/home/Last.vue')
      },
      {
        path: 'sell',
        name: 'sell',
        component: () => import( /* webpackChunkName: "mall" */ '../components/home/Sell.vue')
      },

    ],
    redirect: 'last'
  },
  {
    path: '/goods/:sp_home_title',
    name: 'goods',
    component: () => import( /* webpackChunkName: "mall" */ '../components/goods/Goods.vue')
  },
  {
    path: '/mall',
    name: 'mall',
    component: () => import( /* webpackChunkName: "mall" */ '../views/mall/Mall.vue')
  },
  {
    path: '/loginPage',
    name: 'loginPage',
    component: () => import( /* webpackChunkName: "mall" */ '../views/LoginPage.vue')
  },
  {
    path: '/mydetail/:goodsId',
    name: 'mydetail',
    component: () => import( /* webpackChunkName: "mall" */ '../views/Mydetail.vue')
  },
  {
    path: '/mydetail/:goodsName',
    name: 'mydetail',
    component: () => import( /* webpackChunkName: "mall" */ '../views/Detail.vue')
  },
  {
    path: '/cart',
    name: 'cart',
    component: () => import( /* webpackChunkName: "mall" */ '../views/Cart.vue')
  },
  {
    path: '/detail_commit',
    name: 'detail_commit',
    component: () => import( /* webpackChunkName: "mall" */ '../views/detai_commit.vue')
  },
  {
    path: '/jia',
    name: 'jia',
    component: () => import( /* webpackChunkName: "mall" */ '../views/Detail.vue')
  },
  {
    path: '/order',
    name: 'order',
    component: () => import( /* webpackChunkName: "mall" */ '../components/Order/Order.vue')
  },
  {
    path: '/mine',
    name: 'mine',
    component: () => import( /* webpackChunkName: "mall" */ '../views/Mine.vue')
  }, 
  {
    path: '/search',
    name: "search",
    component: () => import( /* webpackChunkName: "search" */ '../components/Search/SearchChlid.vue')
  },
  {
    path: '/pay',
    name: "pay",
    component: () => import( /* webpackChunkName: "search" */ '../views/Pay.vue')
  },
  {
    path: '/all',
    name: "all",
    component: () => import( /* webpackChunkName: "search" */ '../components/Mine/all.vue')
  },
  {
    path: '/setting',
    name: "setting",
    component: () => import( /* webpackChunkName: "search" */ '../views/Setting.vue')
  },
  {
    path: '/ship',
    name: "ship",
    component: () => import( /* webpackChunkName: "search" */ '../views/Ship.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0}
  }
})

export default router